package systems;

import models.ApplicationTemplateModel;
import models.SiteConfigModel;
import entities.ApplicationTemplate;
import entities.SiteConfig;

public class ConfigSystem {
    private static SiteConfig configs = null;
    
    private static ApplicationTemplate template = null;
    
    public static SiteConfig getConfigs() {
        if (configs == null) {
            SiteConfigModel sModel = SiteConfigModel.getInstance();
            setConfigs(sModel.getConfig(1));
        }
        
        return configs;
    }

    public static void setConfigs(SiteConfig configs) {
        ConfigSystem.configs = configs;
    }
    
    public static ApplicationTemplate getTemplate() {
    	if (template == null && configs != null) {
    		ApplicationTemplateModel appTemplateModel = ApplicationTemplateModel.getInstance();
    		template = appTemplateModel.get(configs.getTemplate());
    	}
    	
    	return template;
    }
    
    public static void setTemplate(ApplicationTemplate template) {
    	ConfigSystem.template = template;
    }
    
    public static void changeTemplate() {
    	if (configs != null) {
    		ApplicationTemplateModel appTemplateModel = ApplicationTemplateModel.getInstance();
    		template = appTemplateModel.get(configs.getTemplate());
    	}
    }
}
